<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script crossorigin src="../js/react.production.min.js"></script>
    <!-- 核心库  最先引用 -->
    <script crossorigin src="../js/react-dom.production.min.js"></script>
    <!-- 引用react-dom 用于支持react操作DOM -->
    <script crossorigin src="../js/babel.min.js"></script>
    <!-- 引入babel 用于将jsx转为js -->
    <title>学习react</title>
</head>

<body>
    <div id="test"></div>

    <script type="text/babel"> // 此处一定要写babel

        class Vdom extends React.Component {
            state = {
                time: new Date()
            }
            componentDidMount() {
                setInterval(() => {
                    this.setState({ time: new Date() });
                }, 1000);
            }
            render() {
                const { time } = this.state
                return (
                    <div>
                        <h1>qwe</h1>
                        <input type="text" />
                        <p>{time.toTimeString()}</p>
                    </div>
                )
            }
        }

        ReactDOM.render(<Vdom />, document.getElementById('test')) //渲染
    </script>
</body>

</html>